<template>
    <ul class="mui-table-view">
        <li v-for="item in newsList" :key="item.id" class="mui-table-view-cell mui-media">
            <router-link :to="'/home/newsInfo/'+item.id">
                <img class="mui-media-object mui-pull-left" :src="item.imgUrl">
                <div class="mui-media-body">
                    <h1>{{item.title}}</h1>
                    <p class='mui-ellipsis'>
                        <span>发表时间：{{item.publishTime | dateFormat}}</span>
                        <span>浏览量：{{item.pageView}}</span>
                    </p>
                </div>
            </router-link>
        </li>
    </ul>
</template>

<script>
import {Toast} from 'mint-ui'
export default {
    data() {
        return {
            newsList: []
        }
    },
    created() {
        this.getNewsList();
    },
    methods: {
        getNewsList(){
            this.axios.get('/admin/new/newsList').then( response => {
                if (response.data.success){
                    this.newsList = response.data.data;
                    Toast("新闻加载成功");
                } else {
                    Toast("新闻加载失败");
                }
            })
        }
    }
}
</script>

<style scoped lang="scss">
.mui-table-view{
    li{
        h1{
            font-size: 14px;
        }
        .mui-ellipsis{
            font-size: 12px;
            display: flex;
            justify-content: space-between;
        }
    }
}
</style>